Windows directory
You can get windows directory be calling GetWindowsDirectory API function.
Example:
- Drop a Label and a Button.
- At buttons OnClick event write:
var
WinDir: PChar;
begin
WinDir:= StrAlloc(100);
GetWindowsDirectory(WinDir, 100);
Label1.Caption:= WinDir;
StrDispose(WinDir);
Notes:
- Befor you pass WinDir variable to GetWindowsDirectory function you must allocate
space in memory for WinDir using SetLength procedure.
- Most of API functions deal with Null-terminated strings, so that you must typecast
AnsiString to Null-terminated string by using PChar type such as:
PChar(WinDir);
- In Windows directory you will find most of Windows applications such as MSPain,
WordPad, NotePad, and many others.
See also:
Windows temporary directory
User name and computer name